package com.numberone.system.util;

import java.security.MessageDigest;
import java.util.UUID;


public class CommonUtilsYpl {

    /**
     * 生成uuid
     * @return
     */
    public  static  String generateUUID(){
       String uuid  = UUID.randomUUID().toString().replaceAll("-","").substring(0,32);
       return uuid;
    }

    /**
     * md5加密
     */
     public static  String MD5(String data){
        try {
            MessageDigest md5  =MessageDigest.getInstance("MD5");
            byte[] array  =  md5.digest(data.getBytes("UTF-8"));
            StringBuilder sb = new StringBuilder();
            for (byte item : array) {
                sb.append(Integer.toHexString((item & 0xFF) | 0x100).substring(1,3));
            }
            return sb.toString().toLowerCase();
        }catch (Exception e){
            e.printStackTrace();
        }
       return null;
     }
}
